/*
 * LoginBL
 * 
 * Version 1.0
 *
 * 23-08-08
 * 
 * Modification Logs:
 *   DATE        AUTHOR      DESCRIPTION
 *  --------------------------------------------------------
 *  23-08-08	TuHA		declare class prototype
 *  29-08-08	TuHA		code functions: LoginBL, isAuthentication
 *  						getLevel, getUserEntity
 */

package vn.fpt.fsoft.fcos.bl;

import vn.fpt.fsoft.fcos.dao.UserDao;
import vn.fpt.fsoft.fcos.entity.UserEntity;

/**
 * This class contains all of business methods can be performed in user 
 * @author TuHA
 *
 */
public class LoginBL {

	// username 
	private String userId;
	
	// password
	private String passwd;
	
	/**
	 * This is constructor to initilize LoginBL
	 * @param userId is userid of user
	 * @param password is password of user
	 */
	public LoginBL(String userId, String password) {
		this.userId = userId;
		this.passwd = password;		
	}
	
	/**
	 * This is the methods 
	 * @return boolean type, it is true if userid is authenticated
	 * 			return false or not
	 */
	public boolean isAuthentication() {
		UserDao userDao = new UserDao();
		
		return userDao.checkPasswd(this.userId, this.passwd);
	}
	
	/**
	 * getLevel is used to get level of this user
	 * @return integer number express level of user
	 */
	public int getLevel() {
		UserDao userDao = new UserDao();
		
		return userDao.getLevel(this.userId, this.passwd);
	}
	
	/**
	 * getUserEntity is used to get user's info from the database
	 * @return the userentity express information of this user 
	 */
	public UserEntity getUserEntity() {
		UserDao userDao = new UserDao();
		
		return userDao.getUserEntity(this.userId, this.passwd);
	}
	
}
